package com.itheima.继承_练习;
/*
注意:Java中定义类时,只能跟一个extends,extends后面只能跟一个类名作为该类的父类
继承的特点:单继承,多层继承


 */
public class Ye {

    String name = "德玛";
    int age = 65;

    public void drink(){
        System.out.println("喝酒");
    }

}

class Fu extends Ye{
    int age = 40;

    public void smoke(){

        System.out.println("抽烟");
    }


}

class Shu extends Ye{
    int age = 38;

    public void tt(){
        System.out.println("烫头");

    }


}

class Zi extends Fu{
    int age = 21;
    //String name = "赵信";
    public void play(){
        System.out.println("玩游戏");
    }

    public void method(){
        int age = 18;
        System.out.println(age);//1.重名时,先找成员变量
        System.out.println(this.age);//2.使用this关键字可以定位到成员变量
        System.out.println(super.age);//使用super关键字直接查询到父类的成员变量
        System.out.println(new Ye().age);//创建对象精准定位
    }

    public void method1(){
        System.out.println(name);//直接打印子类成员变量
        /*System.out.println(super.name);//super打印父类成员变量
        System.out.println(super.name);//先找*/


    }

}

class Demo{
    public static void main(String[] args) {
       Zi zi = new Zi();
       /*  zi.play();
        zi.drink();
        zi.smoke();
        //zi.tt();
        String st = new String("asd");
        System.out.println(st);*/
      zi.method();
      zi.method1();

      String str = "asda";
      str = str.replace("a","C" );
        System.out.println(str);
    }


}
